<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>提现设置</title>
  <link rel="stylesheet" href="./css/bootstrap.css">
  <script src="./js/jquery-3.2.1.js"></script>
  <script src="./js/ajaxfileupload.js"></script>
  <style>
    .input-group > .form-control{
      /* flex:0 0 auto; */
    }
    .sendPic{
      width:120px;
      height:120px;
      border:1px dotted gray;
      line-height: 120px;
      text-align: center;
      box-shadow: 0 0 2px gray;
    }
    .zhifu{
      /* vertical-align: top; */
    }
    .myImg{
      
    }
  </style>
</head>
<body>
  <div class="container-fiuld p-3">
    <div class="card w-75">
      <div class="card-header border-0 d-flex flex-column-reverse">
        <h3>提现设置</h3>
      </div>
      <div class="card-body w-50">
        <form>
          <div class="input-group mb-3">
            <div class="input-group-prepend">
              <span class="input-group-text">提现联系人手机号</span>
            </div>
            <input type="text" class="form-control" placeholder="（请填写真实号码）">
          </div>

          <div class="input-group mb-3">
            <div class="input-group-prepend">
              <span class="input-group-text">支付宝账号</span>
            </div>
            <input type="text" class="form-control" placeholder="（请填写真实的支付宝账号）">
          </div>

          <div class="input-group mb-3">
            <div class="input-group-prepend">
              <span class="input-group-text">支付宝姓名</span>
            </div>
            <input type="text" class="form-control" placeholder="（与代理商老板一致的开户名）">
          </div>

          <div class="mb-3 row">
            <span class="col-lg-3 zhifu">支付宝收款码</span>
            <input type="file" id="pic" class="form-control d-none" placeholder="（绑定之后无权自主修改）">
            <div class="col-lg-4">
              <div class="sendPic">
                <i class="layui-icon layui-icon-add-1"></i>
                <img src="" alt="" style="display:none" class="myImg">
              </div>
            </div>
          </div>
          <button type="button" class="ml-5 btn btn-primary ">提交</button>
          <button type="button" class="btn btn-secondary ">取消</button>    
        </form>
      </div>
      <div class="card-footer bg-transparent border-0">
      </div>
    </div>
  </div>
  <script>
    //触发事件
    $(".sendPic").click(function(){
      $("#pic").click();
      $("#pic").change(function(){
        var imgUrl = getObjectURL(this.files[0])
      })
      //传图片
      console.log($.ajaxFileUpload)
      $.ajaxFileUpload({
        url:"uploadHeadPic",//
        fileElementId: "upload", //文件上传域的ID，这里是input的ID，而不是img的
        dataType: 'json', //返回值类型 一般设置为json
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        success: function (data) {
            alert(data.code+" "+ data.msg);
            if (data.code==200){
                $("#headPic").attr("src","/market/images/image.png");
                //将图片换成默认的+图片
            }  
        }
      
      })
    })
    /*$("#submit_btn").click(function () {
      var imgurl = document.getElementById("upload").value;
      $.ajaxFileUpload({
        url:"uploadHeadPic",
        fileElementId: "upload", //文件上传域的ID，这里是input的ID，而不是img的
        dataType: 'json', //返回值类型 一般设置为json
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        success: function (data) {
            alert(data.code+" "+ data.msg);
            if (data.code==200){
                $("#headPic").attr("src","/market/images/image.png");
                将图片换成默认的+图片
            }  
        }
      
      })
    })*/
    //获取图片路径
    function getObjectURL(file) {
      var url = null ;
      if (window.createObjectURL!=undefined) { // basic
          url = window.createObjectURL(file) ;
      } else if (window.URL!=undefined) { // mozilla(firefox)
          url = window.URL.createObjectURL(file) ;
      } else if (window.webkitURL!=undefined) { // webkit or chrome
          url = window.webkitURL.createObjectURL(file) ;
      }
      return url ;
    }

  </script>
</body>
</html>